import java.sql.*;
public class Life {
	public static void main(String[] args) {
		int i = 0;
		String s[] = new String[10000];
		Connection con;
		Statement sql;
		ResultSet rs;
		con = GetDBConnection.connectDB("world", "root", "");
		if (con == null) return;
		String sqlStr = "select *from country where LifeExpectancy != 0 order by LifeExpectancy";
		try{
			sql = con.createStatement();
			rs = sql.executeQuery(sqlStr);
			while (rs.next()) {
				String Name = rs.getString(2);
				Float LifeExpectancy = rs.getFloat(8);
				s[i] = Name + "寿命为：" + LifeExpectancy;
				i++;
			}
			System.out.printf("寿命最短的国家是:%s\n", s[0]);
			System.out.printf("寿命最长的国家是:%s\n", s[i-1]);
			con.close();
		}
		catch(SQLException e){
			System.out.println(e);
		}
	}

}

